function workout() {
    let gym = 'Gym A';
    const gymStatuses =  {'Gym A': 'open', 'Gym B': 'closed'};

    for(let gym in gymStatuses) {
        console.log('1: ' + gym + ' is ' + gymStatuses[gym]);
    }

    {
        const gym = 'Gym B';
        console.log('2: ' + 'Workout in ' + gym);
        //下面语句有错 常量不能赋值
        //TypeError: Assignment to constant variable.
        //gym = 'Gym C';
    }

    console.log('3: ' + 'Workout in ' + gym);   //是第二行的gym

    {
        //作用域
        function gym() {
            console.log('4: ' + 'Workout in a separate gym');
        }
        gym();
    }

    if(gymStatuses[gym] == 'open') {
        let exercises = ['Treadmill', 'Pushup', 'Spinning'];
    }

    //exercises在if范围之内访问不了
    //console.log(exercises);

    try {
        let gym = 'Gym C';
        console.log('Workout in ' + gym); //Workout in Gym C
        throw new Error('Gym is closed'); 
    } catch (err) {
        console.log(err);
        let gym = 'Gym D';
        console.log('Workout in ' + gym);  //Workout in Gym D
    }
}

workout();